﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>UrlLib</title>
    <script src="../../../UrlLib.js"></script>
    <script src="http://js.lzlcdn.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <!--[if lt IE 8]>
    <script src="//js.lzlcdn.com/js/tools/json2.min.js"></script>
    <![endif]-->

    <style>
        html, body {
            padding: 0;
            margin: 0;
        }

        .item {
            border: 1px solid green;
            margin: 5px 1px;
            overflow: hidden;
        }

        .title {
            border-bottom: 2px solid #808080;
            padding: 5px;
            word-break: break-all;
            word-wrap: break-word;
        }

        .content {
            padding: 5px;
            overflow: auto;
            *word-break: break-all;
            *word-wrap: break-word;
        }
    </style>
</head>
    <body>
        <a href="//test.html">test</a>
        <script>
            var urls = [
                'http://dcfm.agoodnet.com/page/common/CheckWeiXin.shtm?ReturnUrl=http%3A%2F%2Fdcfm.agoodnet.com%2FPage%2FUser%2FFavorites.shtml%3FOrganId%3D81e410c9-47d6-4d52-a452-1c4553635581%26BusinessId%3D3cf87633-5a47-40af-bdad-03d4afbcb497%26ShopId%3Dbef6a29c-aaca-4ceb-83d8-310ae1320787%26t%3D1476236240138&OrganId=81e410c9-47d6-4d52-a452-1c4553635581&BusinessId=3cf87633-5a47-40af-bdad-03d4afbcb497&ShopId=bef6a29c-aaca-4ceb-83d8-310ae1320787&t=1476236243291',
                'https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=js%20url&oq=%E6%88%91%E7%9A%84ip&rsv_pq=aae48102000128e1&rsv_t=7518cEjQ6QQoc38eY4SKESaolXZGfnE5TngNyX%2FLmrhlzpe%2FnsORybD7hbk&rqlang=cn&rsv_enter=1&rsv_sug3=5&rsv_sug1=5&rsv_sug7=101&rsv_sug2=0&inputT=5313&rsv_sug4=5312',
                'HTTPS://WWW.BAIDU.COM/S?IE=UTF-8&F=8&RSV_BP=1&TN=BAIDU&WD=JS%20URL&OQ=%E6%88%91%E7%9A%84IP&RSV_PQ=AAE48102000128E1&RSV_T=7518CEJQ6QQOC38EY4SKESAOLXZGFNE5TNGNYX%2FLMRHLZPE%2FNSORYBD7HBK&RQLANG=CN&RSV_ENTER=1&RSV_SUG3=5&RSV_SUG1=5&RSV_SUG7=101&RSV_SUG2=0&INPUTT=5313&RSV_SUG4=5312',
                "../../js/commBiz.js?v=20161011165047#qwe",
                "../Order/OrderList.shtml?orderPayState=1",
                "//test.fresh300.com/Order/OrderList.shtml?orderPayState=1",
                "../../Page/User/Index.shtml#fsdf?b=dsfrd",
                "Page/User/Index.shtml#fsdf?b=dsfrd",
                "Index.shtml#fsdf?b=dsfrd"
            ];

            $.each(urls, function (i, item) {
                var div = $('<div class="item"/>').appendTo(document.body).click(function () {
                    var url = $(this).data('item');
                    var o = UrlLib.getUrlInfo(url);
                    check(item, o);
                }).data('item', item);
                $('<div class="title"/>').text(item).appendTo(div);
                var obj = UrlLib.getUrlInfo(item);
                var json = JSON.stringify(obj, null, 4);
                $('<pre class="content"/>').text(json).appendTo(div);
                check(item, obj);
            });

            function check(url, data) {
                if (/^\w+\:\/\//.test(data.href) && (data.fullPath + data.search + data.hash).toLowerCase() != data.href.toLowerCase()) {
                    alert('fullpath error:' + url);
                }
                var a = document.createElement('a');
                try {
                    a.href = url;

                } catch (e) {
                    console.error(e);
                    alert(e);
                }
            }

            if ("geolocation" in navigator) {
                /* 地理位置服务可用 */
            }
        </script>
    </body>
</html>
